// lib\widgets\proportional_text_row.dart
import 'package:flutter/material.dart';

class ProportionalTextRow extends StatelessWidget {
  final List<String> texts;
  final List<int> flexValues;
  final double fontSize;

  const ProportionalTextRow({
    super.key,
    required this.texts,
    required this.flexValues,
    this.fontSize = 16.0,
  }) : assert(texts.length == flexValues.length, 'texts 和 flexValues 的长度必须一致');

  @override
  Widget build(BuildContext context) {
    List<Widget> _buildTextWidgets() {
      return texts
          .asMap()
          .map((index, text) {
            return MapEntry(
              index,
              Expanded(
                flex: flexValues[index],
                child: Text(
                  text,
                  textAlign: TextAlign.justify,
                  style: TextStyle(
                      fontSize: fontSize,
                      color: Colors.black,
                      backgroundColor: Colors.red
                  ),
                ),
              ),
            );
          })
          .values
          .toList();
    }

    return Row(
      children: _buildTextWidgets(),
    );
  }
}
